package chapter03;

public class Test01_inherit {
    public static void main(String[] args) {
        Dog d = new Dog("小黄",5,"黄色");
//        d.setName("小黄");
//        d.setAge(5);
//        d.setColor("黄色");
        System.out.println(d.getName());
        System.out.println(d.getAge());
        System.out.println(d.getColor());
        d.shout();
    }
}
class Animal{
    private String name;
    private int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public void shout(){
        System.out.println("发出声音");
    }
}
class Dog extends Animal{
    public Dog(String name,int age,String color){
        super(name,age);//先调用父类的构造函数
        this.color = color;
    }
    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
    // overwrite overload
    public void shout(){
        super.shout();//使用super关键字调用父类的方法
        System.out.println("汪汪");
    }
    private String color;
    //定义一个table类 用一个子类继承table computertable
    //table的属性颜色和材质 computertable 升降范围
    //定义get和set方法和构造函数
}
